<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
                template="../../Templates/SubFolderTemplate.xhtml"
                xmlns:p="http://primefaces.prime.com.tr/ui"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core">
    <ui:define name="head-title">
        <title>Add New Customer | Merlion's ERP System</title>
    </ui:define>
    
    
    <ui:define name="content">
        <f:view beforePhase="#{addDepositManagerBean.initView}">
        <h:form>
            <p:panel id="panel" header="Make Deposit for Customer"> 
                <p:ajaxStatus style="width:16px;height:16px;">   
                    <f:facet name="start">   
                        <p:graphicImage value="http://www.primefaces.org:8080/showcase/design/ajaxloading.gif" /> 
                    </f:facet> 
 
                    <f:facet name="complete">   
                        <h:outputText value="" />   
                    </f:facet>   
                </p:ajaxStatus> 
 
                <p:messages /> 
 
                <h:panelGrid columns="4" cellpadding="10"> 
                    
                    
                    <h:outputLabel for="customerName" style="font-weight: bold" value="Search Company: " /> 
                    <p:autoComplete value="#{addDepositManagerBean.saleLeadName}" required="true"
                                    id="customerName" label="customerName" requiredMessage="Company Name is required." completeMethod="#{addDepositManagerBean.complete}">
                    </p:autoComplete>
                    <p:message for="customerName" />                         
                        
                    <br></br>
                    
                <p:fieldset legend="Credit Account Information" rendered="#{addDepositManagerBean.isExisting}">
                    
                    <h:panelGrid columns="3">
                    <h:outputLabel for="registrationNumber" style="font-weight: bold" value="Registration Number: "  /> 
                    <h:outputText id="registrationNumber" value="#{addDepositManagerBean.selectedCustomer.registrationNumber}"> 
                    </h:outputText> 
                    <p:message for="registrationNumber" /> 
 
                    <h:outputLabel for="creditAccountId" style="font-weight: bold" value="Credit Account ID: " rendered="#{addDepositManagerBean.isExisting}"/> 
                    <h:outputText id="creditAccountId" value="#{addDepositManagerBean.selectedCustomer.creditAccount.creditAccountId}">                         
                    </h:outputText> 
                    <p:message for="creditAccountId" /> 
                    
                    <h:outputLabel for="deposit" style="font-weight: bold" value="Deposit ($): " rendered="#{addDepositManagerBean.isExisting}"/> 
                    <h:outputText id="deposit" value="#{addDepositManagerBean.selectedCustomer.creditAccount.deposit}">                         
                    </h:outputText> 
                    <p:message for="deposit" /> 
                    
                    <h:outputLabel for="creditLimit" style="font-weight: bold" value="Credit Limit: " rendered="#{addDepositManagerBean.isExisting}"/> 
                    <h:outputText id="creditLimit" value="#{addDepositManagerBean.selectedCustomer.creditAccount.creditLimit}">                         
                    </h:outputText> 
                    <p:message for="creditLimit" />
                    </h:panelGrid>
                </p:fieldset>
                        
                        <br></br>
                        
                <p:fieldset legend="Deposit Information" rendered="#{addDepositManagerBean.isExisting}">
                    <h:outputLabel for="depositAdd" style="font-weight: bold" value="Money to add deposit($): " /> 
                    <p:inputText id="depositAdd" value="#{addDepositManagerBean.depositAdd}"  rendered="#{addDepositManagerBean.isExisting}">                         
                    </p:inputText> 
                    <p:message for="depositAdd" />
                
                    <p:commandButton id="btn" value="Save New Deposit" update="panel" actionListener="#{addDepositManagerBean.saveNewDeposit}" ajax="true" rendered="#{addDepositManagerBean.isExisting}"/>
                
                </p:fieldset>
                    
                </h:panelGrid>
                <p:commandButton value="Retrieve Information" update="panel" actionListener="#{addDepositManagerBean.retrieve}" ajax="true"/>
                </p:panel> 
        </h:form>
        </f:view>
        
    </ui:define>

</ui:composition>
